Skip to content

Conversation

wsmoses
Copy link
Member

@wsmoses wsmoses commented Sep 13, 2025

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Sep 13, 2025

@llvm/pr-subscribers-debuginfo

@llvm/pr-subscribers-llvm-transforms

Author: William Moses (wsmoses)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/158448.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/Utils/SimplifyCFG.cpp (+4-2)
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 5a842f9b49c1b..6d6e32d51b62e 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -3387,11 +3387,13 @@ bool SimplifyCFGOpt::speculativelyExecuteBB(BranchInst *BI,
   // Metadata can be dependent on the condition we are hoisting above.
   // Strip all UB-implying metadata on the instruction. Drop the debug loc
   // to avoid making it appear as if the condition is a constant, which would
-  // be misleading while debugging.
+  // be misleading while debugging. However, make sure to keep debug info
+  // for calls as inlinable function calls in a function with debug info must
+  // have a !dbg location.
   // Similarly strip attributes that maybe dependent on condition we are
   // hoisting above.
   for (auto &I : make_early_inc_range(*ThenBB)) {
-    if (!SpeculatedStoreValue || &I != SpeculatedStore) {
+    if (!SpeculatedStoreValue || &I != SpeculatedStore && !isa<CallBase>(&I)) {
       I.setDebugLoc(DebugLoc::getDropped());
     }
     I.dropUBImplyingAttrsAndMetadata();

Copy link

github-actions bot commented Sep 13, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Contributor

@fhahn fhahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test?

@wsmoses
Copy link
Member Author

wsmoses commented Sep 14, 2025

Yeah, though I'm a bit unsure how to set one up for this part of the pass

@wsmoses
Copy link
Member Author

wsmoses commented Sep 14, 2025

@fhahn okay figured it out, can you give it a review?

@nikic nikic self-requested a review September 14, 2025 16:19
@nikic nikic changed the title Refine metadata handling during instruction hoisting [SimplifyCFG] Refine metadata handling during instruction hoisting Sep 14, 2025
Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wsmoses wsmoses merged commit c44e015 into main Sep 15, 2025
11 checks passed
@wsmoses wsmoses deleted the users/wsmoses/dbg branch September 15, 2025 03:50
giordano pushed a commit to JuliaLang/llvm-project that referenced this pull request Sep 15, 2025
giordano pushed a commit to JuliaLang/llvm-project that referenced this pull request Sep 15, 2025
wsmoses added a commit to wsmoses/llvm-project that referenced this pull request Sep 15, 2025
giordano pushed a commit to JuliaLang/llvm-project that referenced this pull request Sep 15, 2025
Zentrik pushed a commit to JuliaLang/llvm-project that referenced this pull request Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants